package off_trial

import (
	sqlc "bp/db/sqlc"
	"bp/internal/render"
	sharedVld "bp/internal/rpcserver/shared/vld"
	"bp/internal/service/com/offer"
	"bp/internal/util"
	offTrialGrpc "bp/rpc/gen/mwebapi/off_trial"
	"context"
)

// VldGetOffTrialInfoReq 验证获取优惠试算信息
func (s *OffTrialMWebApiImp) VldGetOffTrialInfoReq(ctx context.Context, q *sqlc.Queries, req *offTrialGrpc.GetOffTrialInfoReq) (ptr *offer.GetTrialInfoParam, err error) {
	slog := util.NewContextLogger(ctx, s.slog)

	if util.IsEmpty(req.OutTransNo) {
		err = render.InvalidArgumentRange("out_trans_no")
		return
	}
	if !sharedVld.IsOfferUseScene(req.TrialScene) {
		err = render.InvalidArgumentValue("trial_scene")
		return
	}
	ptr = &offer.GetTrialInfoParam{
		OutTransNo: req.OutTransNo,
		TrialScene: req.TrialScene,
	}
	slog.Infof("off_trial_imp/cmd_vld.VldGetOffTrialInfoReq ok")
	return
}
